Skip to content

fix: validate sampling/createMessage with correct schema#1387

Closed
yaonyan wants to merge 3 commits intomodelcontextprotocol:mainfrom
yaonyan:fix/sampling-tools-validation
Closed

fix: validate sampling/createMessage with correct schema#1387
yaonyan wants to merge 3 commits intomodelcontextprotocol:mainfrom
yaonyan:fix/sampling-tools-validation

Conversation

@yaonyan
Copy link

@yaonyan yaonyan commented Jan 15, 2026

Summary

Select the correct schema (CreateMessageResultWithToolsSchema vs CreateMessageResultSchema) based on whether tools were provided in the request.

Motivation and Context

Standard validation was incorrectly rejecting tool call arrays in sampling results because it was always using the non-tool schema. This allows clients to correctly receive tool use content from models.

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have read the MCP Documentation

@yaonyan yaonyan requested a review from a team as a code owner January 15, 2026 03:13
@changeset-bot
Copy link

changeset-bot bot commented Jan 15, 2026

🦋 Changeset detected

Latest commit: 9081c72

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 15, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1387

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1387

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1387

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1387

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1387

commit: 9081c72

@yaonyan
Copy link
Author

yaonyan commented Jan 22, 2026

I just checked and saw it's actually been fixed, closing it
Clipboard_Screenshot_1769073977

@yaonyan yaonyan closed this Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant